package com.suemi.missile.client;


import com.suemi.missile.client.ESConnection;
import com.suemi.missile.client.IndexManager;
import com.suemi.missile.common.entity.ESDocument;
import com.suemi.missile.common.entity.Patent;
import com.suemi.missile.common.utils.Constants;
import com.suemi.missile.common.utils.ExcelParser;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.stream.Collectors;

public class Test {


  public static void main(String[] args) throws IOException, InvalidFormatException, URISyntaxException {

    ESConnection conn = new ESConnection();
    IndexManager manager = conn.getIndexer();

    Long counts = conn.countAll();
    System.out.println(counts==null?-1:counts);

    List<ESDocument> documents = conn.list(1000);

    if(documents!=null)
      for(ESDocument document:documents)
        System.out.println(document.getPatent().applicant);

    MissileQuery query = new MissileQuery("localhost",9200);
    documents = query.mqlQuery("SELECT * FROM patents WHERE applicationNumber CONTAINS \"CN\" ;").getDocuments();
    for(ESDocument document:documents)
      System.out.println(document.documentId());
  }
}
